home *** CD-ROM | disk | FTP | other *** search
- #include <intuition/screens.h>
- #include <libraries/asl.h>
- #include <clib/exec_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/asl_protos.h>
- #include <clib/dos_protos.h>
-
- static struct Library *AslBase;
- static struct NameInfo nameinfo;
- static struct DimensionInfo dimension;
-
- static struct Rectangle MinMaxSize = { 640,400, 3000,3000 };
-
-
- #define FILENAMELEN 256
- /*
- * GetScreenMode liefert eine DisplayModeID zurück, die der Benutzer
- * gewählt hat. Der Funktion muß ein Zeiger auf einen
- * Screen übergeben werden. Der Funktion KANN ein Zeiger
- * auf ein TagArray übergeben werden, in dem weitere
- * Spezifikationen stehen. Damit nimmt einem die Funktion
- * alles allgemeine Gedöns ab und läßt einem doch alle
- * Freiheiten.
- *
- * Input struct Screen *s Zeiger auf einen Screen
- * struct TagList *tl Zeiger auf ein TagArray
- * ULONG *Farben Zeiger auf ein ULONG, um die
- * Anzahl der gewählten Farben
- * abzulegen. Kann NULL sein.
- *
- * Output ULONG DisplayModeID eine DisplayModeID, wenn der
- * Benutzer etwas gewählt hat
- * 0 bei Abbruch
- *
- * Bemerkungen Die Funktion öffnet und schließt selbst die Asl-
- * Library. Es wird mindestens die Version 38 verlangt.
- *
- * Datum 22. März 1993
- * letzte Änder. 22. März 1993
- * Autor David Göhler
- *
- */
-
-
-
- /*
- ASLSM_FilterFunc (struct Hook *) - A function to call for each mode
- encountered. If the function returns TRUE, the mode is
- included in the file list, otherwise it is rejected
- and not displayed. The function receives the following
- parameters:
- A0 - (struct Hook *)
- A1 - (ULONG) mode id
- A2 - (struct ScreenModeRequester *)
- (V38)
- */
-
- /*
- __geta4 __regargs ULONG SMFilterFunction(__A0 struct Hook * hooki, __A1 ULONG id,
- __A2 struct ScreenModeRequester *SMR)
- {
- DisplayInfoHandle Handle;
- ULONG retcode = 0;
-
- if (Handle = FindDisplayInfo(id))
- {
- if ( GetDisplayInfoData (Handle,&dimension,sizeof(dimension),
- DTAG_DIMS,0))
- {
- if ((dimension.Nominal.MaxX <= MinMaxSize.MaxX) &&
- (dimension.Nominal.MaxX >= MinMaxSize.MinX) &&
- (dimension.Nominal.MaxY <= MinMaxSize.MaxY) &&
- (dimension.Nominal.MaxY >= MinMaxSize.MinY))
- {
- retcode = 1;
- }
- }
- }
-
- return retcode;
- }
- */
-
- LONG GetScreenMode(struct Screen *s,struct TagList *tl, ULONG *Farben)
- {
- LONG retcode = -1L;
- struct ScreenModeRequester *smr = 0L;
-
- if (s == 0) return retcode;
-
- if (AslBase = OpenLibrary(AslName,38L))
- {
- if (smr = AllocAslRequestTags(ASL_ScreenModeRequest,
- ASLSM_Screen, s,
- ASLSM_TitleText, "Bitte ScreenMode wählen:",
- ASLSM_PositiveText, "Wählen",
- ASLSM_NegativeText, "Abbrechen",
- ASLSM_DoDepth, TRUE,
- ASLSM_DoWidth, TRUE,
- ASLSM_DoHeight, TRUE,
- ASLSM_PropertyFlags, DIPF_IS_WB,
- // ASLSM_FilterFunc, SMFilterFunction,
- ASLSM_MinWidth, 640L,
- ASLSM_MinHeight, 400L,
- // ASLSM_MaxWidth, 800L,
- // ASLSM_MaxHeight, 600L,
-
- ASLSM_InitialWidth, 260L,
- ASLSM_InitialHeight, (s->Height-(s->BarHeight+1)) / 2,
- ASLSM_InitialLeftEdge, (s->Width-260) / 2,
- ASLSM_InitialTopEdge, s->BarHeight,
- TAG_DONE))
- {
- if (AslRequest((APTR)smr,tl)) // wenn, dann hat der User gewählt
- { retcode = smr->sm_DisplayID;
- if (Farben)
- { *Farben = smr->sm_DisplayDepth; }
- }
- FreeAslRequest(smr);
- }
- else
- { // melde("Konnte ScreenModeRequest nicht öffnen",FALSE,0,0);
- }
- CloseLibrary(AslBase);
- AslBase = 0L;
- }
- else
- { // melde("Konnte asl.library version 38 oder höher nicht öffnen", FALSE,0,0);
- }
-
- return retcode;
- }
-
-
-
- char *GetNameFromMonitorID(ULONG MonitorID)
- {
- DisplayInfoHandle Handle;
- char *retstring = 0;
-
- if (!ModeNotAvailable (MonitorID))
- {
- if (Handle = FindDisplayInfo(MonitorID))
- {
- if ( GetDisplayInfoData (Handle,&nameinfo,sizeof(nameinfo),
- DTAG_NAME,0))
- {
- retstring = nameinfo.Name;
- }
- }
- }
-
- return retstring;
- }
-
-
- LONG GetMaxDepthFromMonitorID(ULONG MonitorID)
- {
- DisplayInfoHandle Handle;
- LONG retcode = 0;
-
- if (!ModeNotAvailable (MonitorID))
- {
- if (Handle = FindDisplayInfo(MonitorID))
- {
- if ( GetDisplayInfoData (Handle,&dimension,sizeof(dimension),
- DTAG_DIMS,0))
- {
- retcode = dimension.MaxDepth;
- }
- }
- }
-
- return retcode;
- }
-
- BOOL InitNewScreenFromMonitorID(ULONG MonitorID, struct NewScreen *ns)
- {
- DisplayInfoHandle Handle;
- BOOL retcode = FALSE;
-
- if (!ModeNotAvailable (MonitorID))
- {
- if (Handle = FindDisplayInfo(MonitorID))
- {
- if ( GetDisplayInfoData (Handle,&dimension,sizeof(dimension),
- DTAG_DIMS,0))
- {
- memset (ns,'\0',sizeof(*ns));
-
- ns->LeftEdge = dimension.Nominal.MinX;
- ns->TopEdge = dimension.Nominal.MinY;
- ns->Width = dimension.Nominal.MaxX;
- ns->Height = dimension.Nominal.MaxY;
-
- //Printf("%ld, %ld, %ld, %ld\n", ns->LeftEdge, ns->TopEdge ,
- // ns->Width, ns->Height);
-
- retcode = TRUE;
- }
- }
- }
-
- return retcode;
- }
-
- /* Syntax : BOOL DateiReq(filename,AnzeigeText,Show)
-
- Datum : 04. November 1989
-
- Eingabe : filename - Zeiger auf den Filenamen
- AnzeigeText - Zeiger auf Text, der oben im Window steht
- Show - Ein String, der ein Pattern enthält. Der FileRequester
- zeigt dann nur Dateien an, die auf das Pattern passen.
-
- Ausgabe : FALSE - Requester mit Cancel verlassen
- TRUE - neuer Dateiname ist gültig
-
- Funktion: Aufruf des 2.0-ASL-FileRequesters. Ein vereinfachtes Beispiel.
- Läuft nur unter 2.0
- */
-
- BOOL DateiReqD(char *filename,char *AnzeigeText,char *Show, BOOL dir)
- {
- struct FileRequester *FR;
- char zwfile[FILENAMELEN];
- char zwdir [FILENAMELEN];
- char *cpoint,c;
- BOOL retcode = FALSE;
- ULONG extflags1;
-
- if (dir) extflags1 = FIL1F_NOFILES; else extflags1 = FIL1F_MATCHDIRS;
-
- if (AslBase = (struct Library *)OpenLibrary(AslName,37))
- {
- // String in filename und dirname aufteilen
- cpoint = PathPart(filename);
- c = *cpoint; *cpoint = '\0';
- strcpy(zwdir,filename);
- if (c=='/') { *cpoint++=c; } else { *cpoint = c; }
- strcpy(zwfile,cpoint);
-
- if (FR = AllocAslRequestTags( ASL_FileRequest,
- ASL_Hail, AnzeigeText,
- ASL_Window, 0L,
- ASL_File, zwfile,
- ASL_Dir, zwdir,
- ASL_FuncFlags, FILF_PATGAD,
- ASL_ExtFlags1, extflags1,
- ASL_Pattern, Show,
- TAG_DONE ))
- {
- if (RequestFile(FR))
- {
- strcpy(filename,FR->rf_Dir);
- AddPart(filename,FR->rf_File,FILENAMELEN);
- retcode = TRUE;
- }
- FreeFileRequest(FR);
- }
- CloseLibrary((struct Library *)AslBase);
- }
- return retcode;
- }
-
- BOOL DateiReq(char *filename,char *AnzeigeText,char *Show)
- {
- return DateiReqD(filename,AnzeigeText,Show,FALSE);
- }
-
-
-